<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>其他收入与支出汇总</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="其他,收入,与,支出,汇总">
	<meta http-equiv="description" content="This is my page">
	
	<style type="text/css">
	.myDiv
	{
		width:110px;
		display:inline;
		float:left;
		border-style:solid;
		border-width:1px;
		border-color:lightblue;
		padding:5px;
		margin:5px;
	}
	
	.yearTb
	{
		display:inline;
		border-style:solid;
		border-width:1px;
		border-color:lightblue;
		padding: 5px;
		margin:10px;
	}
	
	.lock
	{
		color:red;
	}
	</style>
	
  </head>
  
  <body>
    <center>
    	<s:form name="frm" id="frm" method="post" action="incomeExpenseCollect" namespace="/inner/charge">
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'费用管理'},{'name':'其他收入与支出汇总'},{'name':'汇总'}]"/>
    			<jsp:param name="width" value="40%"/>
    		</jsp:include>
    		
    		<s:hidden name="kindergartenId" id="kindergartenId"></s:hidden>
    		<s:hidden name="thisYear" id="thisYear"></s:hidden>
    		<s:hidden name="lockMonth" id="lockMonth"></s:hidden>
    		
    		<br>
    		<table width="720px" cellspacing="1" cellpadding="3">
    			<tr>
    				<td height="30px" align="center" valign="middle" style="font-size:16px; font-weight:bold;">
    					其他收入与支出汇总
    				</td>
    			</tr>
    		</table>
    		<table width="720px" cellspacing="1" cellpadding="3" class="yearTb">
    			<tr>
    				<td align="center" valign="middle">
    					<table>
    						<tr>
    							<td height="30px" align="center" valign="middle" colspan="6" style="font-size:16px;">
   									<s:property value="thisYear"/>年
    							</td>
    						</tr>
							<tr>
								<s:iterator id="i" value="monthList" status="s">
									<td width="120px" height="50px" align="center">
										<div class="myDiv" align="center">
											<div style="display:inline-block;">
												<a href="javascript:showMonthIncomeExpense('<s:property value="value"/>')">
													<s:property value="label"/>
												</a>
												<my:hasPermission privilegeId="incomeExpenseLock">
												&nbsp;
												<a id="a<s:property value='%{thisYear}'/>_<s:property value='value'/>" href="javascript:lockOrUnLockThisMonth('<s:property value="value"/>')">
													<font id="f<s:property value='%{thisYear}'/>_<s:property value='value'/>">上锁</font>
												</a>
												</my:hasPermission>
											</div>
										</div>
									</td>
									<s:if test="#s.count % 6 == 0">
										</tr>
										<tr>
									</s:if>
								</s:iterator>
							</tr>
						</table>
    				</td>
    			</tr>
    		</table>
    		<br>
    		<br>
    			
    		<s:if test='otherYearList.size != 0'>
    		<table width="720px" cellspacing="1" cellpadding="3" class="yearTb">
    			<tr>
    				<td align="center" valign="middle">
    					<table>
    						<tr>
    							<td height="30px" align="center" valign="middle" colspan="6" style="font-size:16px;">
    								其他年份
    							</td>
    						</tr>
							<tr>
								<s:iterator id="i" value="otherYearList" status="s">
									<td width="120px" align="center">
										<div class="myDiv" align="center">
											<div style="display:inline-block;" align="center">
												<a href="javascript:toIncomeExpenseCollect('<s:property value="year"/>')">
													<s:property value="year"/>年
												</a>
											</div>
										</div>
									</td>
									<s:if test="#s.count % 6 == 0">
										</tr>
										<tr>
									</s:if>
								</s:iterator>
							</tr>
						</table>
    				</td>
    			</tr>
    		</table>
   			</s:if>
    		
    		<s:iterator value="lockList" status="s">
    			<s:hidden name="yearHid" value="%{year}"></s:hidden>
    			<s:hidden name="monthHid" value="%{month}"></s:hidden>
    		</s:iterator>
    	</s:form>
    </center>
    
    <script type="text/javascript">
    var lockStr = '上锁';
    var unLockStr = '解锁';
    
    $(function(){
    	lockInit();
    });
    
    function showMonthIncomeExpense(month)
    {
    	var thisYear = $('#thisYear');
    	var kgId = getTopKg();
    	var url = realPath + '/inner/charge/getReportList.action?ievo.year=' + thisYear.val() +'&ievo.month='+month + '&kindergartenId=' + kgId;
    	window.location.href = url;
    }
    
    function lockOrUnLockThisMonth(month)
    {
    	var thisYear = $('#thisYear');
    	var f = $('#f' + thisYear.val() + '_' + month);
    	showConfirm('确认' + month + '月' + f.text() + '？', function(v){
    		if(v == true)
    		{
    			var lockMonth = $('#lockMonth');
    			lockMonth.val(month);
    			if(lockStr == f.text())
		    	{
		    		ajaxAction('inner/charge/addLock.action', 'post', 'frm', false);
		    		f.text(unLockStr);
		    		f.addClass('lock');
		    	}
		    	else
		    	{
		    		ajaxAction('inner/charge/delLock.action', 'post', 'frm', false);
		    		f.text(lockStr);
		    		f.removeClass('lock');
		    	}
    		}
    	});
    }
    
    function lockInit()
    {
    	var yearHid = $('input:hidden[name="yearHid"]');
    	var monthHid = $('input:hidden[name="monthHid"]');
    	var len = yearHid.length;
    	for(var i = 0; i < len; i++)
    	{
    		var lockYear = $(yearHid.get(i));
    		var lockMonth = $(monthHid.get(i));
    		var f = $('#f' + lockYear.val() + '_' + lockMonth.val());
    		f.text(unLockStr);
    		f.addClass('lock');
    	}
    }
    
    function toIncomeExpenseCollect(year)
    {
    	var thisYear = $('#thisYear');
    	thisYear.val(year);
    	document.forms['frm'].submit();
    }
    
    </script>
  </body>
</html>
